package org.jetlinks.pro.koudai.web;


import io.swagger.v3.oas.annotations.tags.Tag;
import org.hswebframework.web.authorization.annotation.Resource;
import org.jetlinks.pro.koudai.Services.CourseTypeService;
import org.jetlinks.pro.koudai.entity.CourseTypeEntity;
import org.jetlinks.pro.koudai.tenant.KoudaiAssetType;
import org.jetlinks.pro.tenant.AssetType;
import org.jetlinks.pro.tenant.crud.TenantCorrelatesAccessCrudController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Nonnull;
import java.util.function.Function;

@RestController
@RequestMapping("/course-type")
@Resource(id = "course-type-manager", name = "课程类型管理")
@Tag(name = "课程类型管理")
public class CourseTypeController implements TenantCorrelatesAccessCrudController<CourseTypeEntity, String> {

    private final CourseTypeService courseTypeService;

    public CourseTypeController(CourseTypeService courseTypeService) {
        this.courseTypeService = courseTypeService;
    }


    @Override
    public CourseTypeService getService() {
        return courseTypeService;
    }

    @Nonnull
    @Override
    public AssetType getAssetType() {
        return KoudaiAssetType.course_type;
    }

    @Nonnull
    @Override
    public Function<CourseTypeEntity, ?> getAssetIdMapper() {
        return CourseTypeEntity::getId;
    }

    @Nonnull
    @Override
    public String getAssetProperty() {
        return "exp_course";
    }
}
